<template>
    <section :style="{background: isComponent ?'#fff':'#ECF0F5',paddingTop:isComponent? '0':'20px'}">
        <!--工具条-->

        <div class="section-content  pb-top clearfix">
            <el-col :span="24" class="toolbar " style="padding-bottom: 0px;">
                <el-form :inline="true" :model="filters">
                    <el-form-item>
                        <el-select v-if="usertype==2" v-model="filters.scade1s" filterable placeholder="请选择组织" size="mini"
                            @change="getUsers()">
                            <el-option label="全选" value=" ">
                            </el-option>
                            <el-option v-for="item in firmlist" :key="item.companyId" :label="item.name" :value="item.companyId">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item>
                        <el-select v-model="filters.deviceTypeId" filterable placeholder="请选择设备类型" @change="deviceget()">
                                <el-option label="全选" value=" ">
                                    </el-option>
                            <el-option v-for="item in typelist" :key="item.id" :label="item.name" :value="item.id"></el-option>

                        </el-select>
                    </el-form-item> -->
                    <!-- <el-form-item>
                        <el-select v-model="filters.terminalUser" placeholder="终端用户" @change="deviceget()">
                            <el-option key=" " label="全选" value=" ">
                            </el-option>
                            <el-option v-for="item in terminal_list" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                        </el-input>
                    </el-form-item> -->
                    <el-form-item v-if="!isComponent">
                        <el-select v-model="filters.deviceId" placeholder="设备" filterable @change="second()" clearable @keyup.enter.native="getUsers()">
                            <!-- <el-option label="全选"></el-option> -->
                            <el-option v-for="item in devicelist" :key="item.deviceId" :label="item.name" :value="item.deviceId">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-select v-model="filters.deviceSlaveId" placeholder="设备从机" @change="getUsers1()" clearable>
                            <!-- <el-option label="全选"></el-option> -->
                            <el-option v-for="item in deviceSlavelist" :key="item.slaveSn" :label="item.name" :value="item.slaveSn">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-select v-model="filters.alarmTypeId" placeholder="告警类型" @change="getUsers1()" clearable>
                            <!-- <el-option label="全选"></el-option> -->
                            <el-option v-for="item in alarmtype" :key="item.id" :label="item.name" :value="item.id">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-select v-model="filters.level" placeholder="告警等级" @change="getUsers1()" clearable>
                            <!-- <el-option label="全选"></el-option> -->
                            <el-option v-for="item in alaem_grade" :key="item.value" :label="item.remark" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-select v-model="filters.state" placeholder="处理状态" @change="getUsers1()" clearable>
                            <!-- <el-option label="全选" value=" "></el-option> -->
                            <el-option key="0" label="未处理" value="0"></el-option>
                            <el-option key="1" label="已处理" value="1"></el-option>
                            <el-option key="2" label="误报" value="2">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item>
                        <el-date-picker v-model="value4" @change="second1()" type="datetimerange" range-separator="至"
                            start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions2">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button :type="buttonColor" v-on:click="getUsers1">查询</el-button>
                    </el-form-item>

                </el-form>
            </el-col>

            <!--列表-->
            <el-table :data="query" class="alarmshistory" :header-row-style="{backgroundColor: titleColor}" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
                <el-table-column type="selection">
                </el-table-column>
                <el-table-column align="center" type="index" label="序号"  width="80":index="indexMethod">
                </el-table-column>
                <el-table-column align="center" prop="deviceName" label="设备名称">
                </el-table-column>

                <el-table-column align="center" prop="alarmTriggerName" label="告警规则">
                        <template scope="scope">
                                <span class="pb-name" @click="triggerslistGet(scope.row)">{{scope.row.alarmTriggerName}}</span>
                            </template>
                </el-table-column>
                <el-table-column align="center" prop="alarmTypeName" label="告警类型">
                    </el-table-column>
                <el-table-column align="center" prop="deviceRecipeBodyName" label="数据点" >
                </el-table-column>
                <el-table-column align="center" prop="levelText" label="告警等级" width="150">
                </el-table-column>

                <el-table-column align="center" prop="triggerValue" label="临界值" width="100">
                </el-table-column>
                <el-table-column align="center" prop="triggerText" label="告警内容" width="165">
                </el-table-column>
                <el-table-column align="center" prop="createTime" label="告警时间" width="200">
                </el-table-column>
                <el-table-column align="center" label="处理时间" width="200">
                    <template scope="scope">
                        <span v-if="scope.row.state!=0">{{scope.row.updateTime}}</span>
                    </template>
                </el-table-column>
                <el-table-column align="center"  label="处理状态" prop="state" :formatter="formatSex">
                </el-table-column>
                <el-table-column align="center" label="操作" width="120">
                    <template scope="scope">
                        <!-- <el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                    <el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button> -->
                        <i v-if="menubt.indexOf('/alarm_log/recover')>-1&&scope.row.state!=1" @click="handleEdit(scope.$index, scope.row)"
                            title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                        <i @click="handleDel(scope.$index, scope.row)" icon="el-icon-delete" circle title="删除" class="pb-icon icon-delete"></i>

                    </template>
                </el-table-column>
            </el-table>

            <!--工具条-->
            <el-col :span="24" class="toolbar">
                <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量处理</el-button>
                <el-button :type="buttonColor" @click="tableToExcel">导出当前页告警记录</el-button>
                <el-pagination layout="sizes,prev, pager, next" @current-change="handleCurrentChange" @size-change="handleSizeChange"
                    :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="total" style="float:right;">
                </el-pagination>
            </el-col>
        </div>
        <!--编辑界面-->
        <el-dialog title="处理告警" v-show="editFormVisible" v-model="editFormVisible" :custom-class="dialogTitleColor" @close="editFormVisible=false">
            <div slot="footer" style="text-align: left; ">
                <el-form :model="editForm" label-width="80px" :rules="editFormRules" ref="editForm">
                    <el-form-item label="处理状态">
                        <el-radio-group v-model="editForm.state">
                            <el-radio label="0">未处理</el-radio>
                            <el-radio label="1">已处理</el-radio>
                            <el-radio label="2">误报</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="处理结果">
                        <el-input type="textarea" v-model="editForm.remark"></el-input>

                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align:right;">
                    <el-button @click.native="editFormVisible = false">取消</el-button>
                    <el-button :type="buttonColor" @click.native="editSubmit" :loading="editLoading">提交</el-button>
                </div>
            </div>
        </el-dialog>

        <!--新增界面-->
        <el-dialog title="新增" v-show="addFormVisible" v-model="addFormVisible" :custom-class="dialogTitleColor" @close="addFormVisible=false">
            <div slot="footer" style="text-align: left; ">
                <el-form :model="addForm" label-width="100px" :rules="addFormRules" ref="addForm">
                    <el-form-item label="名字" prop="name">
                        <el-input v-model="addForm.name" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="电话号码" prop="name">
                        <el-input v-model="addForm.phone" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="email" prop="name">
                        <el-input v-model="addForm.email" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="微信" prop="name">
                        <el-input v-model="addForm.weixin" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="备注">
                        <el-input type="textarea" v-model="addForm.remark"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align: right;">
                    <el-button @click.native="addFormVisible = false">取消</el-button>
                    <el-button :type="buttonColor" @click.native="addSubmit" :loading="addLoading">提交</el-button>
                </div>
            </div>
        </el-dialog>
    </section>
</template>

<script>
    // import util from './../common/js/util'
    //import NProgress from 'nprogress'
    import {
        alarm_log_query,
        alarms_query_user,
        alarms_post_user,
        alarms_delete_user,
        alarms_put_user,
        alarm_log_get,
        alarm_log_recover,
        device_query_mini,
        alarm_type_query,
        device_get,
        dict_query,
        alarm_log_delete,
        user_query,
        terminal_user_query,
        device_type_query,
        user_querycompany
    } from '../../api/api';

    export default {
        props:{
            isComponent:{//判断当前页面是否被作为组件使用
                type: Boolean,
                default: false
            },
        },
        data() {
            return {
                usertype: '',
                firmlist: '',
                typelist: '',
                terminal_list: '',
                pickerOptions2: {
                    shortcuts: [{
                        text: '最近1小时',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 1);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近24小时',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 1);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一周',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                pageSize: 10,
                alaem_grade: '',
                devicelist: '',
                deviceSlavelist: '',
                alarmtype: '',
                value4: [],
                filters: {
                    deviceId: '',
                    deviceSlaveId: '',
                    alarmTypeId: '',
                    state: '',
                    startTime: '',
                    endTime: '',
                    level: '',
                    scade1s: '',
                    deviceTypeId: '',
                    terminalUser: ''
                },
                query: [],
                total: 0,
                page: 1,
                listLoading: false,
                sels: [], //列表选中列

                editFormVisible: false, //编辑界面是否显示
                editLoading: false,
                editFormRules: {
                    name: [{
                        required: true,
                        message: '请输入姓名',
                        trigger: 'blur'
                    },{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }]
                },
                //编辑界面数据
                editForm: {
                    idList: [],
                    state: '',
                    remark: '',

                },

                addFormVisible: false, //新增界面是否显示
                addLoading: false,
                addFormRules: {
                    name: [{
                        required: true,
                        message: '请输入姓名',
                        trigger: 'blur'
                    },{ min: 1, max: 20, message: '长度在 1 到 20 个字符', trigger: 'blur' }],
                    path: [{
                            required: true,
                            message: '请输入path',
                            trigger: 'blur'
                        }

                    ]
                },
                //新增界面数据
                addForm: {
                    name: '',
                    phone: '',
                    email: '',
                    weixin: '',
                    remark: ''
                }

            }
        },
        computed:{
            buttonColor(){
                return this.$store.state.buttonColor
            },
            titleColor(){
                return this.$store.state.titleColor
            },
            dialogTitleColor(){
                return this.$store.state.dialogTitleColor
            },
        },
        methods: {
            getUsers1(){
                this.page=1;
                this.total=0;
                this.getUsers();
            },
            triggerslistGet(row){
                sessionStorage.setItem('facility_alarmTriggerId', row.alarmTriggerId)
                this.$router.push({
                    path: '/alarms/triggerslist'
                })
            },
            indexMethod(index) {
                let num = (this.page - 1) * this.pageSize + index + 1;
                return num;
            },
            tableToExcel() {
                var jsonData = []
                console.log(this.query)
                for (let i in this.query) {
                    jsonData[i] = {
                        deviceName: this.query[i].deviceName,
                        deviceSn: "SN: " + this.query[i].deviceSn,
                        deviceRecipeBodyName: this.query[i].deviceRecipeBodyName,
                        alarmTriggerName: this.query[i].alarmTriggerName,
                        triggerText: this.query[i].triggerText,
                        levelText: this.query[i].levelText,
                        createTime: this.query[i].createTime,
                        updateTime: this.query[i].updateTime,
                        triggerValue: this.query[i].triggerValue,
                        state: this.query[i].state,
                        remark: this.query[i].remark,

                    }
                    if (jsonData[i].state == 0) {

                        jsonData[i].state = '未处理';
                        jsonData[i].updateTime = '';
                    } else if (jsonData[i].state == 1) {
                        jsonData[i].state = '已处理';

                    } else if (jsonData[i].state == 2) {
                        jsonData[i].state = '误报';

                    }
                    if (!jsonData[i].remark) {
                        jsonData[i].remark = '';
                    }
                }
                var str = '设备名称,网关SN,数据点,告警名称,告警内容,告警等级,告警时间,处理时间,临界值,处理状态,处理措施\n';
                //循环遍历，每行加入tr标签，每个单元格加td标签
                for (let i = 0; i < jsonData.length; i++) {
                    for (let item in jsonData[i]) {
                        //增加\t为了不让表格显示科学计数法或者其他格式
                        str += `${ jsonData[i][item] + ',\t'}`;
                    }
                    str += '\n';
                }
                //encodeURIComponent解决中文乱码
                    let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str);
                    //通过创建a标签实现
                    let link = document.createElement("a");
                    link.href = uri;
                    //对下载的文件命名
                    link.download =  "告警记录.csv";
                    document.body.appendChild(link);
                    link.click();
                    document.body.removeChild(link);

    //             //列标题
    //             var str =
    //                 '<tr><td>设备名称</td><td>序列号</td><td>数据点</td><td>告警等级</td><td>告警时间</td><td>处理时间</td><td>临界值</td><td>处理状态</td><td>处理结果</td></tr>';
    //             //循环遍历，每行加入tr标签，每个单元格加td标签
    //             for (let i = 0; i < jsonData.length; i++) {
    //                 str += '<tr>';
    //                 for (let item in jsonData[i]) {
    //                     //增加\t为了不让表格显示科学计数法或者其他格式
    //                     str += `<td>${ jsonData[i][item] + '\t'}</td>`;
    //                 }
    //                 str += '</tr>';
    //             }
    //             //Worksheet名
    //             var worksheet = 'Sheet1'
    //             var uri = 'data:application/vnd.ms-excel;base64,';

    //             //下载的表格模板数据
    //             var template =
    //                 `<html xmlns:o="urn:schemas-microsoft-com:office:office" 
    //   xmlns:x="urn:schemas-microsoft-com:office:excel" 
    //   xmlns="http://www.w3.org/TR/REC-html40">
      
    //     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    //   <head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
    //     <x:Name>${worksheet}</x:Name>
    //     <x:Name>${worksheet}</x:Name>
    //     <x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
    //     </x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
    //     </head><body><table>${str}</table></body></html>`;
    //             //下载模板
    //             window.location.href = uri + this.base64(template)

            },
            base64(s) {
                return window.btoa(unescape(encodeURIComponent(s)))
            },
            getdata(date) {
                var y = date.getFullYear();
                var m = date.getMonth() + 1;
                m = m < 10 ? ('0' + m) : m;
                var d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                var h = date.getHours();
                h = h < 10 ? ('0' + h) : h;
                var minute = date.getMinutes();
                minute = minute < 10 ? ('0' + minute) : minute;
                var second = date.getSeconds();
                second = second < 10 ? ('0' + second) : second;
                return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;

            },
            //性别显示转换
            second1() {
                this.filters.startTime = this.getdata(this.value4[0]);
                this.filters.endTime = this.getdata(this.value4[1]);
                this.getUsers();
            },
            second() {
                this.filters.deviceSlaveId = "";
                this.getUsers();
                if (this.filters.deviceId) {
                    let para = {
                        deviceId: this.filters.deviceId,
                    };
                    device_get(para).then((res) => {
                         this.begCode(res.code,res.message);
                        if (res.code == 0) {
                            //NProgress.done();
                            this.deviceSlavelist = res.data.deviceSlaveList;
                            console.log(this.deviceSlavelist)

                        }

                    });
                } else {
                    this.deviceDataRecipeBody = {};
                }
            },
            formatSex: function (row, column) {
                return row.state == 2 ? '误报' : row.state == 1 ? '已处理' : row.state == 0 ? '未处理' : '未知';
            },
            handleSizeChange(val) {
                this.pageSize = val;

                this.getUsers();
            },
            handleCurrentChange(val) {
                this.page = val;
                this.getUsers();
            },
            //获取菜单列表
            getUsers() {
                if (this.menubt.indexOf('/alarm_log/query') == -1) {
                    this.$message({
                        message: '您没有查询告警记录权限',
                        type: 'warning'
                    });
                    return false;
                }
                let para = {

                    pageNo: this.page,
                    pageSize: this.pageSize,
                    deviceId: this.filters.deviceId,
                    deviceSlaveId: this.filters.deviceSlaveId,
                    alarmTypeId: this.filters.alarmTypeId,
                    state: this.filters.state,
                    startTime: this.filters.startTime,
                    endTime: this.filters.endTime,
                    level: this.filters.level,
                    companyId:this.filters.scade1s
                    

                };
                this.listLoading = true;
                //NProgress.start();
                alarm_log_query(para).then((res) => {
                     this.begCode(res.code,res.message);
                    this.total = res.data.totalCount;
                    this.query = res.data.list;
                    this.page=res.data.pageNo
                    this.listLoading = false;
                    //NProgress.done();
                });


            },
            //删除
            handleDel: function (index, row) {
                this.$confirm('确认删除该告警记录吗?', '提示', {
                    type: 'warning'
                }).then(() => {
                    this.listLoading = true;
                    //NProgress.start();
                    let para = {

                        idList: [row.id]
                    };
                    alarm_log_delete(para).then((res) => {
                         this.begCode(res.code,res.message);
                        if (res.code == 0) {

                            this.listLoading = false;
                            //NProgress.done();
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            this.getUsers();

                        }
                    });
                }).catch(() => {

                });
            },
            //显示编辑界面
            handleEdit: function (index, row) {

                this.editForm.idList = [];
                let para = {
                    id: row.id
                };

                alarm_log_get(para).then((res) => {
                     this.begCode(res.code,res.message);

                    this.editLoading = false;
                    if (res.code == 0) {
                        //NProgress.done();
                        this.editFormVisible = true;
                        this.editForm.idList.push(res.data.id);
                        this.editForm.remark = res.data.remark;
                        this.editForm.state = res.data.state.toString();
                    }
                });

            },
            //显示新增界面
            handleAdd: function () {
                this.addFormVisible = true;
                this.addForm = {
                    name: '',
                    sex: -1,
                    age: 0,
                    birth: '',
                    addr: ''
                };
            },
            //编辑
            editSubmit: function () {
                this.$refs.editForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.editLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.editForm);

                            alarm_log_recover(para).then((res) => {
                                 this.begCode(res.code,res.message);

                                this.editLoading = false;
                                if (res.code == 0) {
                                    //NProgress.done();
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                    this.$refs['editForm'].resetFields();
                                    this.editFormVisible = false;
                                    this.getUsers();
                                }
                            });
                        });
                    }
                });
            },
            //新增
            addSubmit: function () {
                this.$refs.addForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {
                            this.addLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.addForm);

                            alarms_post_user(para).then((res) => {
                                 this.begCode(res.code,res.message);
                                this.addLoading = false;
                                //NProgress.done();
                                this.$message({
                                    message: '提交成功',
                                    type: 'success'
                                });
                                this.$refs['addForm'].resetFields();
                                this.addFormVisible = false;
                                this.getUsers();
                            });
                        });
                    }
                });
            },
            selsChange: function (sels) {
                this.sels = sels;
            },
            //批量修改

            batchRemove: function () {
                for(let i in this.sels){
                    if(this.sels[i].state == 1){
                        this.$message({
                            type:'warning',
                            message:'选择中含有已处理的警告'
                        })
                        return false
                    }    
                }
                var ids = this.sels.map(item => item.id).toString();
                // this.listLoading = true;
                //NProgress.start();
                this.editForm.idList = ids.split(',');
                this.editForm.remark = "";
                this.editForm.state = '0';
                this.editLoading = false;

                this.editFormVisible = true;
                // alarms_delete_user(para).then((res) => {
                //      this.begCode(res.code,res.message);
                //     this.listLoading = false;
                //     //NProgress.done();
                //     this.$message({
                //         message: '删除成功',
                //         type: 'success'
                //     });
                //     this.getUsers();
                // });

            },
            deviceget() {
                let para = {
                    pageNo: this.page,
                    pageSize: 9999,
                    deviceTypeId: this.filters.deviceTypeId,
                    terminalUser: this.filters.terminalUser,
                    miniLev:2,

                    companyId: this.filters.scade1s,

                };
                // this.filters.deviceId='';
                //NProgress.start();
                device_query_mini(para).then((res) => {
                     this.begCode(res.code,res.message);
                    this.devicelist = res.data.list;
                    //NProgress.done();
                });
            }
        },
        mounted() {
            console.log(sessionStorage.getItem('time'))
            // this.filters.state=this.$route.query.state;
            this.filters.state=localStorage.getItem('facility_state')
            this.menubt = localStorage.getItem('menubt');
            if(localStorage.getItem('user')){
                this.usertype = JSON.parse(localStorage.getItem('user')).type;
            }
            let para = {
                pageNo: this.page,
                pageSize: 9999

            };
            this.deviceget();
            this.listLoading = true;
            //NProgress.start();
         
            alarm_type_query(para).then((res) => {
                 this.begCode(res.code,res.message);
                this.alarmtype = res.data.list;
                //NProgress.done();
            });
            let para2 = {
                name: 'alarmLevel',
                pageSize: 999,
                pageNo: 1,
            }

            dict_query(para2).then((res) => {
                 this.begCode(res.code,res.message);
                if (res.code == 0) {
                    this.addLoading = false;

                    this.alaem_grade = res.data.list;


                }

            });
            let parauser = {
                pageNo: 1,
                pageSize: 9999,
                type: 1
            }

            user_querycompany(parauser).then((res) => {

                 this.begCode(res.code,res.message);
                this.firmlist = res.data.list;


            });
            let para3 = {
                pageNo: 1,
                pageSize: 9999,
            };
            //NProgress.start();
            terminal_user_query(para3).then((res) => {
                 this.begCode(res.code,res.message);
                this.terminal_list = res.data.list;
                //NProgress.done();
            });
            device_type_query(para3).then((res) => {
                 this.begCode(res.code,res.message);
                this.typelist = res.data.list;
                //NProgress.done();
            });
            
            this.filters.deviceId=localStorage.getItem('facility_details');
            if(sessionStorage.getItem('time')){
                let start1 = new Date(sessionStorage.getItem('time'));
                let start2 = new Date(sessionStorage.getItem('time'));
                start1.setTime(start1.getTime() -   1000 * 1 * 1);
                start2.setTime(start2.getTime()+   1000 * 1 * 1);
                // this.filters.startTime=sessionStorage.getItem('time')
                // this.filters.endTime=sessionStorage.getItem('time')
                this.value4 = [this.getdata(start1), this.getdata(start2)];
                this.filters.startTime = this.getdata(start1);
                this.filters.endTime = this.getdata(start2);
            }
            sessionStorage.removeItem('time');
            this.getUsers();
            console.log(this.filters.startTime)
            console.log(this.filters.endTime)

        }
    }
</script>

<style>
    /* .el-table {
        overflow-y: scroll;
        max-height: 500px;
    } */
    /* .alarmshistory>.el-table__body-wrapper{
        overflow-y: auto;
        height: 500px;
    } */
</style>